/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2023-2023.
 * Description: rtos its enhance feature functions
 * Author: huyizhou
 * Create: 2023-09-14
 */

static struct page *its_allocate_prop_table(gfp_t gfp_flags);
static void gic_reset_prop_table(void *va);

static struct page *its_allocate_general_prop_table(gfp_t gfp_flags)
{
	struct page *prop_page;
	prop_page = alloc_rsv_pages(LPI_PROPBASE_SZ);
	if (!prop_page)
		return its_allocate_prop_table(gfp_flags);

	gic_reset_prop_table(page_address(prop_page));

	return prop_page;
}

static struct page *its_allocate_pending_table(gfp_t gfp_flags);

static struct page *its_allocate_general_pending_table(gfp_t gfp_flags)
{
	struct page *pend_page;
	/* try alloc page from rsv region first */
	pend_page = alloc_rsv_pages(LPI_PENDBASE_SZ);
	if (!pend_page)
		return its_allocate_pending_table(gfp_flags);
	gic_flush_dcache_to_poc(page_address(pend_page), LPI_PENDBASE_SZ);
	return pend_page;
}
